package com.shenmazong.order.controller;

import com.shenmazong.order.pojo.TbProduct;
import com.shenmazong.order.service.TbProductService;
import com.shenmazong.utils.ResultResponse;
import com.shenmazong.vo.IdVo;
import com.shenmazong.vo.PageVo;
import com.shenmazong.vo.SearchInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 军哥
 * @version 1.0
 * @description: TbProductController
 * @date 2022/8/4 10:55
 */

@RestController
@Slf4j
@RequestMapping(value = "/product")
public class TbProductController {

    @Autowired
    TbProductService tbProductService;

    @PostMapping(value = "/add")
    public ResultResponse add(@RequestBody TbProduct tbProduct) {
        return tbProductService.add(tbProduct);
    }

    @PostMapping(value = "/get")
    public ResultResponse get(@RequestBody IdVo idVo) {
        return tbProductService.get(idVo);
    }

    @PostMapping(value = "/set")
    public ResultResponse set(@RequestBody TbProduct tbProduct) {
        return tbProductService.set(tbProduct);
    }

    @PostMapping(value = "/list")
    public ResultResponse list(@RequestBody PageVo pageVo) {
        return tbProductService.listByPage(pageVo);
    }

    @PostMapping(value = "/searchByWord")
    public ResultResponse searchByWord(@RequestBody SearchInfoVo searchInfoVo) {
        return tbProductService.searchByWord(searchInfoVo);
    }

    @PostMapping(value = "/searchByRange")
    public ResultResponse searchByRange(@RequestBody SearchInfoVo searchInfoVo) {
        return tbProductService.searchByRange(searchInfoVo);
    }
}
